<?php
/**
 * @fileoverview    找回密码填写完新密码提交的接口
 * @author          zhanglei11
 * @date            Thu Jan 05 14:34:25 CST 2012
 * @copyright       sina meila
 */
include_once '../../__global.php';

class aj_setPwd extends ml_controller{
    private $pwd;    
    private $pwd_confirm;
    private $active_code;
    

    function initParam() {
        $this->pwd = $this->input('pwd','P');                    //密码
        $this->active_code = $this->input('active_code','P');    //确码
    }
    
    function main(){
        // 获取当前登录用户 id？   $this->email.'|MEILA|'.time()
        $arr = ml_tool_securecode::passport_decrypt($this->active_code);
        
        $email = $arr[0];
        $time = $arr[1];
        
        /*
        $this->active_code = base64_decode($this->active_code);        
        $email = $arr_code['0'];
        $time = $arr_code[1];
        */
        
        /*
        $session = self::getSession();
        $uid = $session->getVal('uid');
        */
        $oAccount = new ml_model_dbUserAccount();
        
        //获取用户信息        
        $rs = $oAccount->getAccountByEmail($email);
        $accountInfo = $oAccount->get_data();
        
        /*
        //如果老密码不相等
        if($accountInfo['password'] != $oAccount->_password_encrypt($this->pwd_old)) {
            $this->api_output(ML_RCODE_PARAM);
        }
        */
        
        $rs = $oAccount->updatePwd($accountInfo['uid'],$this->pwd);
        
        if($rs) { //  成功
            $this->api_output(ML_RCODE_SUCC);
        }else {   //  修改密码失败
            $this->api_output(ML_RCODE_FAIL);
        }
    }



    function checkParam() {      
        $this->check_referer();
        
    }

}

new aj_setPwd();

